﻿using System;
using System.Configuration;
using System.Xml;

namespace Alex.Library.Log.Configuration
{
    /// <summary>
    /// 创建文件行为枚举内容元素
    /// </summary>
    public sealed class CreateFileBehaviorContentElement : EnumContentElement<CreateFileBehavior>
    {
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public CreateFileBehaviorContentElement()
        {
            this.Value = CreateFileBehavior.ByDay;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="serializeCollectionKey"></param>
        protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
        {
            CreateFileBehavior behavior = CreateFileBehavior.ByDay;
            object obj = reader.ReadElementContentAsString();
            if (obj != null)
            {
                Enum.TryParse<CreateFileBehavior>(obj.ToString(), out behavior);
            }
            this.Value = behavior;
        }
    }
}
